#include  <math.h>
#include <stdio.h>
main()
{		 		 		 
    double  pi, sum = 0, term, sign = 1.0;
    int     count = 0, n = 1;
    do
    {		 		 		 
        term = sign / n;         	     //1
        sum = sum + term;          	//1
        count++;                 	//1
        sign = -sign;              	//1
        n = n + 2;                   	//1
    }
    while (fabs(term) >= 1e-4);  	//1
    pi = sum * 4;   
    printf("pi = %f\ncount = %d\n", pi, count);
}		 		 		 